<template>
	<view class="site-content">
		<view class="site-list-row" v-for="(item,index) in siteList" :key="index">
			<view class="site-img" :style="`background-image:url(${item.siteCover})`">
				<view class="grade">{{'4.5'}}</view>
			</view>
			<view class="site-location">
				<text class="location-text">{{item.siteName}}</text>
				<view class="positioning">
					<image class="positioning_image" src="@/static/img/site/location.png" alt=""></image>
					<view class="text">
						<text>{{item.siteAddress}}</text>
					</view>
				</view>
				<view class="detail-btn-row">
					<u-button @click="detailHandle(item.id)" type="default" shape="circle" class="detail-btn" hover-class="none">详情
					</u-button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { API } from '../../config/myApi.js';
	export default {
		data() {
			return {
				siteList: [],
				id: '',
			}
		},
		onLoad() {
			this.getSiteList();
		},
		methods: {
			getSiteList() {
				const pram = {
					page: 0,
					rows: 10
				}
				API.getSiteList(pram).then(res=> {
					if(res.code==200) {
						const data = res.result.rows;
						this.siteList = data;
					}
					console.log("kkkkk",this.siteList)
				})
			},
			detailHandle(id) {
				console.log('gggg',id)
				uni.navigateTo({
					url:`/pages/site/detail?id=${id}`
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.site-content {
		padding: 0rpx 30rpx;
		background: #F5F5F5;
		overflow: hidden;

		.site-list-row {
			padding: 19rpx 32rpx 23rpx 20rpx;
			background: #fff;
			border-radius: 14rpx;
			margin-top: 26rpx;
			display: flex;
			position: relative;
			.site-img {
				width: 240rpx;
				height: 190rpx;
				border-radius: 6rpx;
				position: relative;
				background-size: cover;
				background-position: center;
				.grade {
					width: 83rpx;
					height: 30rpx;
					position: absolute;
					top: 0;
					left: 0;
					font-size: 20rpx;
					color: #fff;
					background-color: rgba(0, 0, 0, .3);
					text-align: center;
					border-bottom-right-radius: 20rpx;
				}
			}

			.site-location {
				width: 500rpx;
				margin-left: 21rpx;
				display: flex;
				flex-direction: column;

				.location-text {
					font-size: 28rpx;
					font-weight: bold;
					color: #333333;
					line-height: 36rpx;
				}

				.positioning {
					display: flex;
					align-items: center;
					margin-top: 18rpx;
					position: relative;
					.positioning_image {
						width: 18rpx;
						height: 22rpx;
						position: absolute;
						top: 8rpx;
						left: 0;
					}
					.text {
						font-size: 24rpx;
						color: #8a8a8a;
						margin-left: 28rpx;
					}
				}

				.detail-btn-row {
					margin-left: auto;
					margin-top: 20rpx;
					// position: relative;
					.detail-btn {
						background-color: #F4333C;
						color: #fff;
						height: 52rpx;
						width: 122rpx;
						font-size: 26rpx;
						position: absolute;
						right: 20rpx;
						bottom: 20rpx;
					}

					.u-hairline-border:after {
						border: none;
					}
				}
			}
		}

		.site-list-row:first-of-type {
			margin-top: 21rpx;
		}
	}
</style>
